//
//  RMMMyHuLiDetailsHeadView.m
//  Romomo
//
//  Created by puman on 2017/1/5.
//  Copyright © 2017年 mazegong. All rights reserved.
//

#import "RMMMyHuLiDetailsHeadView.h"

@implementation RMMMyHuLiDetailsHeadView
{
    UILabel *_promptLabel;
    UIImageView *_imageV;
    UILabel *_nameLabel;
    UILabel *_timeLabel;
    UILabel *_instructionsLabel;
    UILabel *_priceLabel;
    UILabel *_shenYuLabel;
    UILabel *_contentLabel;
    UIView *_view;
    UIView *_backView;
    UIView *_yanQView;

}
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kCColor;
        
        _yanQView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWideth, 80)];
        _yanQView.backgroundColor = kCColor;
        [self addSubview:_yanQView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, _yanQView.width, 40)];
        label.font = kFont(13);
        label.textColor = COLORFROMCODE(0x9B9B9B, 1);
        label.text = @"套餐即将到期,您可以通过[一键延期]获取更多使用时间";
        [RMMFileManager changeLabelTextColorOneWithLabel:label forRange:NSMakeRange(12, 6) byColor:kBasicColor];
        [_yanQView addSubview:label];
        
        _yanQBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _yanQBut.frame = CGRectMake(kScreenWideth / 2 - 60, label.bottom , 120, 40);
        _yanQBut.layer.masksToBounds = YES;
        _yanQBut.backgroundColor = kBasicColor;
        [_yanQBut setTitle:@"去延期" forState:(UIControlStateNormal)];
        [_yanQBut setTitleColor:kWhiteColor forState:(UIControlStateNormal)];
        _yanQBut.titleLabel.font = kFont(16);
        _yanQBut.layer.cornerRadius = kMaric;
        [_yanQView addSubview:_yanQBut];

        _backView = [[UIView alloc] initWithFrame:CGRectMake(15, _yanQView.bottom + 15, self.width - 30, 135 + (_backView.width - kMaric))];
        _backView.layer.masksToBounds = YES;
        _backView.layer.cornerRadius = 5;
        _backView.backgroundColor = kWhiteColor;
        [self addSubview:_backView];
        
        _imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, _backView.width - kMaric, _backView.width - kMaric)];
        _imageV.layer.masksToBounds = YES;
        _imageV.layer.cornerRadius = 3;
        [_backView addSubview:_imageV];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageV.left, _imageV.bottom, _imageV.width, 30)];
        _nameLabel.font = kFont(16);
        [_backView addSubview:_nameLabel];
        
//        _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_backView.width - 90, _imageV.top, 88, kMaric)];
//        _priceLabel.font = kFont(16);
//        _priceLabel.textAlignment = NSTextAlignmentRight;
//        [_backView addSubview:_priceLabel];
//
//        _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageV.right + 10, _nameLabel.bottom + 10, _backView.width - _imageV.right - kMaric, kMaric + kHalf)];
//        _contentLabel.font = kFont(13);
//        _contentLabel.numberOfLines = 0;
//        _contentLabel.textColor = COLORFROMCODE(0xA0A5A7, 1);
//        [_backView addSubview:_contentLabel];

        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, _nameLabel.bottom, _backView.width - 20, 20)];
        _timeLabel.font = kFont(12);
        [_backView addSubview:_timeLabel];
        
        _instructionsLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, _timeLabel.bottom, _timeLabel.width, 20)];
        _instructionsLabel.textColor = COLORFROMCODE(0x9B9B9B, 1);
        _instructionsLabel.font = kFont(12);
        [_backView addSubview:_instructionsLabel];
        
        UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, _instructionsLabel.bottom + 9.5, _backView.width - 20, 0.5)];
        lineLabel.backgroundColor = RGBA(221, 221, 221, 1);
        [_backView addSubview:lineLabel];

        _shenYuLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, lineLabel.bottom, 200, 45)];
        _shenYuLabel.textColor = kBasicColor;
        _shenYuLabel.font = kFont(14);
        [_backView addSubview:_shenYuLabel];

        _bookingBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _bookingBut.frame = CGRectMake(_backView.width - 75, lineLabel.bottom + 8.5, 60, 28);
        _bookingBut.layer.masksToBounds = YES;
        _bookingBut.layer.borderColor = kBasicColor.CGColor;
        _bookingBut.layer.borderWidth = 1;
        _bookingBut.backgroundColor = kWhiteColor;
        [_bookingBut setTitle:@"预约" forState:(UIControlStateNormal)];
        [_bookingBut setTitleColor:kBasicColor forState:(UIControlStateNormal)];
        _bookingBut.titleLabel.font = kFont(16);
        _bookingBut.layer.cornerRadius = 14;
        [_backView addSubview:_bookingBut];
    }
    return self;
}
- (void)setIsHide:(BOOL)isHide{
    if (isHide) {
        _yanQView.hidden = YES;
        _backView.frame = CGRectMake(15, 15, kScreenWideth - 30, 135 + (_backView.width - kMaric));
    } else {
        _yanQView.hidden = NO;
        _backView.frame = CGRectMake(15, _yanQView.bottom + 15, kScreenWideth - 30, 135 + (_backView.width - kMaric));
    }
}
- (void)setModel:(RMMHuLiModel *)model{
    [_imageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kBaseImageUrl,model.SER_URL]] placeholderImage:[UIImage imageNamed:@"加载中@3x"]];
    _nameLabel.text = model.NAME;
    _timeLabel.text = [NSString stringWithFormat:@"有效期至%@",model.END_DATE];
   // _priceLabel.text = [NSString stringWithFormat:@"¥%@",model.PRICE];
   // CGFloat width = [UILabel backHeightWithString:_priceLabel.text CGFloatCount:20 metho:WIDTH font:16] + 5;
  //  _priceLabel.frame = CGRectMake(_backView.width - width - 2, _imageV.top, width, kMaric);
   // _nameLabel.frame = CGRectMake(_imageV.right + kRow, _imageV.top, _backView.width - _imageV.right - width - 2, kMaric);
    _shenYuLabel.text = [NSString stringWithFormat:@"剩余%@次",model.AVA_QTY];
    _instructionsLabel.text = [NSString stringWithFormat:@"限%@使用",model.REGION];
    [RMMFileManager changeLabelTextColorOneWithLabel:_instructionsLabel forRange:NSMakeRange(1, _instructionsLabel.text.length - 3) byColor:kBasicColor];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
